import { Toast } from "@nutui/nutui-react-taro";
import { View } from "@tarojs/components";
import { useState } from "react";

const ToastUi = () => {
  const [toastState, setToastState] = useState({
    msg: "toast",
    type: "text",
    cover: false,
    duration: 2,
    closeOnOverlayClick: false,
    icon: "",
    center: true,
    visible: false, // 添加一个 visible 状态用于控制 Toast 的显示与隐藏
  });

  return (
    <View>
      <Toast
        msg={toastState.msg}
        visible={toastState.visible}
        type={toastState.type}
        onClose={() => {
          setToastState((prev) => ({ ...prev, visible: false }));
        }}
      />
    </View>
  );
};

export default ToastUi;
